<!--# layout("/common/layout.html",{"jsBase":"/js/consultVideo/consultVideo/"}){ -->

<form class="layui-form layui-form-pane" id="addForm" enctype="multipart/form-data"  lay-filter="editform">
    <input type="hidden" name="id" id="id">

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                 <label class="layui-form-label">标题</label>
				<div class="layui-input-inline">
                                <input type="text" name="title" id="title" autocomplete="off"  class="layui-input" style= "width: 500px">
				</div>
            </div>

    </div><!--form item-->
    </div><!--row-->
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <layui:image id="cover" tagName="封面" tips=""/>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">视频地址</label>
				<div class="layui-input-inline">
                    <input type="text" name="mediaUrl" id="mediaUrl" autocomplete="off"  class="layui-input" style= "width: 500px">
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">云视频ID</label>
                    <div class="layui-input-inline">
                        <input type="text" name="fileId" id="fileId" autocomplete="off"  class="layui-input" >
                    </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">视频类型</label>
				<div class="layui-input-inline">
                                <layui:simpleDataSelect name="videoType" value="${has(consultVideo)?consultVideo.videoType:''}" data="${videoTypeList}"
                                            attrId="value" attrName="name" laySearch="true" />
				</div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">展示平台</label>
                <div class="layui-input-inline">
                    <select  name="come" selectValue="" promtion="请选择" lay-filter="come">
                        <option value="1">pc</option>
                        <option value="2">h5</option>
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">是否可用</label>
				<div class="layui-input-inline">
                    <input type="radio" name="videoStatus" value="1" title="是" checked="" >
                    <input type="radio" name="videoStatus" value="0" title="否">
				</div>
            </div>
        </div>
    </div>
    <layui:submitButtons id="addButton" />
</form>
<!--#} -->
<script>
    Common.initImage();
layui.extend({
    loading: '../../../plugins/layui_extends/loading/loading',
}).define([ 'form', 'laydate', 'table','loading','consultVideoApi'], function(exports) {
    var form = layui.form;
    var consultVideoApi = layui.consultVideoApi;
    var index = layui.index;
    var isNew = true;
    <!--# if(!(isEmpty(consultVideoJson))){  -->
    isNew = false;
    <!--# } -->
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                // $("#addButton").hide();
                // $("#addButton-loading").show();
                // $("#addButton-loading").loading();
                form.on('submit(form)', function(){
                    consultVideoApi.saveForm(isNew,$('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("保存成功");
                        Lib.closeFrame();
                    });
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    view.init();
    <!--# if(!(isEmpty(consultVideoJson))){  -->
    var formJson = ${consultVideoJson};
    form.val("editform",formJson);
    $(".image-preview").each(function() {
        $(this).attr("src",formJson[$(this).attr("id")]);
    });
    <!--# } -->
});
</script>
